﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Globalization;
using Telerik.Web.UI;
using KPIS.GERP.GHRMS.BLL;
using KPIS.GERP.GHRMS.APP.Classes;
using _WebShared.Classes;

namespace KPIS.GERP.GHRMS.APP.App_UI.UserControls
{
    public partial class PS_EmployeeTrainingHistories : System.Web.UI.UserControl
    {
        //private object _dataItem = null;
        //I_HRM_MP_Jobsites job = new B_HRM_MP_Jobsites();
        //I_HRM_MP_WorkAreas area = new B_HRM_MP_WorkAreas();
        //I_HRM_MP_JobsiteLevels lv = new B_HRM_MP_JobsiteLevels();
        //I_HRM_MP_JobsiteCommands cmd = new B_HRM_MP_JobsiteCommands();
        //I_MAS_Nationalities nat = new B_MAS_Nationalities();
        //I_MAS_Districts dis = new B_MAS_Districts();
        //Main main = new Main();

        //protected void Page_Load(object sender, EventArgs e)
        //{
        //    LoadDDLJobsiteUpperSeq();
        //    LoadDDLWorkAreaSeq();
        //    LoadDDLJobsiteLevelSeq();
        //    LoadDDLDistrictSeq();

        //    if (DataItem != null)
        //    {
        //        if (!(DataItem is Telerik.Web.UI.GridInsertionObject))
        //        {
        //            ddlWorkAreaSeq.SelectedValue = Convert.ToString(DataBinder.Eval(DataItem, "work_area_seq"));
        //            ddlJobsiteUpperSeq.SelectedValue = Convert.ToString(DataBinder.Eval(DataItem, "upper_job_site_seq"));
        //            ddlJobsiteLevelSeq.SelectedValue = Convert.ToString(DataBinder.Eval(DataItem, "job_site_level_seq"));
        //            ddlDistrictSeq.SelectedValue = Convert.ToString(DataBinder.Eval(DataItem, "district_seq"));
        //            //((RadGrid)RadPanelBar1.Items[0].FindControl("RadGridHistory")).DataSource = cmd.SelectJobsiteCommandDtls(lblJobsiteSeq.Text);
        //        }
        //        else
        //        {
        //            ddlJobsiteUpperSeq.SelectedValue = ((RadTreeView)Page.FindControl("RadTreeView1")).SelectedValue;
        //            ddlJobsiteUpperSeq.Enabled = false;
        //            lblMode.Text = "เพิ่มข้อมูลใหม่";
        //            imgMode.ImageUrl = "~/App_UI/Images/Buttons/saveDisk.gif";
        //        }
        //    }
        //}

        //public object DataItem
        //{
        //    get
        //    {
        //        return this._dataItem;
        //    }
        //    set
        //    {
        //        this._dataItem = value;
        //    }
        //}

        //protected void LoadDDLJobsiteUpperSeq()
        //{
        //    ddlJobsiteUpperSeq.DataSource = job.SelectDropDownList(Session["SystemJobsiteUpperSeq"].ToString()
        //        , Request.QueryString["IsInternal"]);//ไปเอาหน่วยงานขึ้นตรงของเจ้าของระบบ จะไม่ error
        //}

        //protected void LoadDDLWorkAreaSeq()
        //{
        //    ddlWorkAreaSeq.DataSource = area.SelectDropDownList();
        //}

        //protected void LoadDDLJobsiteLevelSeq()
        //{
        //    ddlJobsiteLevelSeq.DataSource = lv.SelectDropDownList();
        //}

        //protected void LoadDDLDistrictSeq()
        //{
        //    DataTable dtb = dis.SelectDropDownList();
        //    RadComboBoxItem Emtyitem = new RadComboBoxItem();

        //    Emtyitem.Text = null;
        //    Emtyitem.Value = null;
        //    ddlDistrictSeq.Items.Add(Emtyitem);

        //    foreach (DataRow dr in dtb.Rows)
        //    {
        //        RadComboBoxItem item = new RadComboBoxItem();

        //        item.Text = dr["DISTRICT_TEXT"].ToString();
        //        item.Value = dr["DISTRICT_SEQ"].ToString();

        //        item.Attributes.Add("DISTRICT_NAME", dr["DISTRICT_NAME"].ToString());
        //        item.Attributes.Add("AMP_NAME", dr["AMP_NAME"].ToString());
        //        item.Attributes.Add("PROV_NAME", dr["PROV_NAME"].ToString());
        //        item.Attributes.Add("COUNTRY_NAME", dr["COUNTRY_NAME"].ToString());

        //        ddlDistrictSeq.Items.Add(item);

        //        item.DataBind();
        //    }
        //}

        ////============================= ControlEvents ======================================

        //protected void cmdAdd_Click(object sender, EventArgs e)
        //{
        //    string strJobsiteRef = txtJobsiteRef.Text.Trim();
        //    string strJobsiteGFMIS = txtJobsiteGFMIS.Text.Trim();
        //    string strJobsiteName = txtJobsiteName.Text;
        //    string strJobsiteNameShort = txtJobsiteNameShort.Text;
        //    string strJobsiteNameEng = txtJobsiteNameEng.Text;
        //    string strIsInternal = Request.QueryString["IsInternal"];
        //    string strWorkAreaSeq = ddlWorkAreaSeq.SelectedValue;
        //    string strJobsiteUpperSeq = ddlJobsiteUpperSeq.SelectedValue;
        //    string strJobsiteLevelSeq = ddlJobsiteLevelSeq.SelectedValue;
        //    string strJobDescription = txtJobDescription.Text;
        //    string strAddress = txtAddress.Text;
        //    string strDistrictSeq = ddlDistrictSeq.SelectedValue;
        //    string strPostalCode = txtPostalCode.Text;
        //    string strDateStart = (txtDateStart.Text.Length > 0 ? txtDateStart.TextWithLiterals.Trim() : "");
        //    string strDateEnd = (txtDateEnd.Text.Length > 0 ? txtDateEnd.TextWithLiterals.Trim() : "");

        //    job.Insert(strJobsiteRef, strJobsiteName, strJobsiteNameShort, strJobsiteNameEng
        //        , strJobsiteUpperSeq, "", strIsInternal, strWorkAreaSeq, strJobsiteGFMIS, strJobsiteLevelSeq
        //        , strJobDescription, strAddress, strDistrictSeq, strPostalCode
        //        , strDateStart, strDateEnd
        //        , "", "U", Session["UserID"].ToString(), DateTime.Now);
        //}

        //protected void cmdUpdate_Click(object sender, EventArgs e)
        //{
        //    string strJobsiteSeq = lblJobsiteSeq.Text;
        //    string strJobsiteRef = txtJobsiteRef.Text.Trim();
        //    string strJobsiteGFMIS = txtJobsiteGFMIS.Text.Trim();
        //    string strJobsiteName = txtJobsiteName.Text;
        //    string strJobsiteNameShort = txtJobsiteNameShort.Text;
        //    string strJobsiteNameEng = txtJobsiteNameEng.Text;
        //    string strIsInternal = Request.QueryString["IsInternal"];
        //    string strWorkAreaSeq = ddlWorkAreaSeq.SelectedValue;
        //    string strJobsiteUpperSeq = ddlJobsiteUpperSeq.SelectedValue;
        //    string strJobsiteLevelSeq = ddlJobsiteLevelSeq.SelectedValue;
        //    string strJobDescription = txtJobDescription.Text;
        //    string strAddress = txtAddress.Text;
        //    string strDistrictSeq = ddlDistrictSeq.SelectedValue;
        //    string strPostalCode = txtPostalCode.Text;
        //    string strDateStart = (txtDateStart.Text.Length > 0 ? txtDateStart.TextWithLiterals.Trim() : "");
        //    string strDateEnd = (txtDateEnd.Text.Length > 0 ? txtDateEnd.TextWithLiterals.Trim() : "");

        //    job.Update(strJobsiteSeq, strJobsiteRef, strJobsiteName, strJobsiteNameShort, strJobsiteNameEng
        //        , strJobsiteUpperSeq, "", strIsInternal, strWorkAreaSeq, strJobsiteGFMIS, strJobsiteLevelSeq
        //        , strJobDescription, strAddress, strDistrictSeq, strPostalCode
        //        , strDateStart, strDateEnd
        //        , "", Session["UserID"].ToString(), DateTime.Now);
        //}

        //protected void CheckDateValid(object source, ServerValidateEventArgs args)
        //{
        //    if (!DateTimeX.IsValidDmyDate(args.Value, true))
        //    {
        //        args.IsValid = false;
        //    }
        //}

        //protected void CheckPostalCode(object source, ServerValidateEventArgs args)
        //{
        //    if (args.Value.Length > 0 && args.Value.Length < 5)
        //    {
        //        args.IsValid = false;
        //    }
        //}
    }
}